<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
use lib\UserCrypt;
class Goods extends Base{
    /**
    *积分商城
    */
    public function goods()
    {
        if(!empty(input("param.page"))){
            $page=input("param.page");
        }else{
            return json(['code' => 501, 'msg' => '当前分页数']);
        }
        $res=Db::name('goods')->where('state',1)->where('num','>',0)->order('id desc')->limit(10*($page-1),10)->select();
        if($res){
            return json(['code' => 200, 'msg' => '成功！','data'=>$res]);
        }else{
            return json(['code' => 500, 'msg' => '查无数据！']);
        }
    }
    // 积分产品详情
    public function goodsDetail()
    {
        if(!empty(input("param.id"))){
            $id=input("param.id");
        }else{
            return json(['code' => 501, 'msg' => '产品id']);
        }
        $res=Db::name('goods')->where('id',$id)->find();
        if($res){
            return json(['code' => 200, 'msg' => '成功！','data'=>$res]);
        }else{
            return json(['code' => 500, 'msg' => '查无数据！']);
        }
    }
}